/**
 * @description order model
 * @author 李哲
 */
const mongoose = require('../db/db');

const schema = mongoose.Schema({
    username: {
        type: String,
        require: true
    },
    shopId: String,
    shopName: String,
    isCanceled: {
        type: Boolean,
        default: false
    },
    address: {
        username: String,
        city: String,
        department: String,
        houseNumber: String,
        name: String,
        phone: Number
    },
    products: [{
        product: {
            shopId: {
                type: String,
                require: true
            },
            name: String,
            imgUrl: String,
            sales: Number,
            price: Number,
            oldPrice: Number,
            tabs: [String]
        },
        orderSales: Number
    }]
}, {
    timestamps: true
})

const order = mongoose.model('order', schema);

module.exports = order